package com.ogawa.project6602.adapter

import android.view.View
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.BaseViewHolder
import com.ogawa.base.utils.imageloader.ImageConfigImpl
import com.ogawa.base.utils.imageloader.ImageLoader
import com.ogawa.project6602.R
import com.ogawa.project6602.activity.*
import com.ogawa.project6602.bean.MusicResponse

class MusicHunYinPlayAdapter :
    BaseQuickAdapter<MusicResponse, BaseViewHolder>(R.layout.item_music_hunyin_play) {
    override fun convert(helper: BaseViewHolder, item: MusicResponse?) {
        item?.let {
            helper.setText(R.id.titleTv, it.name)
            var musicIv = helper.getView<ImageView>(R.id.Iv)
            var statusIv = helper.getView<ImageView>(R.id.statusIv)
            when (it.status) {
                MUSIC_STATUS_EMPTY -> {
                    musicIv.setImageResource(R.drawable.img_mode)
                    helper.setText(R.id.titleTv, it.name)
                    helper.setTextColor(R.id.titleTv, mContext.resources.getColor(R.color.color18))
                }
                MUSIC_STATUS_READY->{
                    ImageLoader.getInstance().loadImage(
                        mContext, ImageConfigImpl.builder()
                            .url(it.downIcon)
                            .imageView(musicIv)
                            .build())
                    statusIv.visibility = View.GONE
                    helper.setTextColor(R.id.titleTv, mContext.resources.getColor(R.color.status_bar_def_color))
                    helper.setText(R.id.titleTv, it.name)

                }
                MUSIC_STATUS_SUSPEND -> {
                    ImageLoader.getInstance().loadImage(
                        mContext, ImageConfigImpl.builder()
                            .url(it.downIcon)
                            .imageView(musicIv)
                            .build())
                    statusIv.visibility = View.VISIBLE
                    statusIv.setImageResource(R.drawable.img_music_play)
                    helper.setTextColor(R.id.titleTv, mContext.resources.getColor(R.color.status_bar_def_color))
                    helper.setText(R.id.titleTv, it.name)
                }
                MUSIC_STATUS_PLAY_ING -> {
                    ImageLoader.getInstance().loadImage(
                        mContext, ImageConfigImpl.builder()
                            .url(it.downIcon)
                            .imageView(musicIv)
                            .build())
                    statusIv.visibility = View.VISIBLE
                    statusIv.setImageResource(R.drawable.img_music_puse)
                    helper.setTextColor(R.id.titleTv, mContext.resources.getColor(R.color.status_bar_def_color))
                    helper.setText(R.id.titleTv, it.name)
                }
                else->{}
            }
        }

    }
}